/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2024-11-13 10:43:33
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-11-13 10:45:25
 * @FilePath: \project\work-tool\experi-api\utils\JWT.js
 * @Description: 
 */
const jwt = require('jsonwebtoken')
const secret = 'this is a secret'

module.exports = {
  generate(data, expiresIn = '1d') {
    return jwt.sign(data, secret, { expiresIn })
  },
  verify(token) {
    try {
        return jwt.verify(token, secret); 
    } catch (error) {
        console.log('time out:', error)
    }
  }
}
